/**
 * 解析http请求
 * @author: sundx
 * @date: 2020-06-06 22:08:21
 * @Last Modified by: sundx
 * @Last Modified time: 2020-06-08 01:39:30
 */
#ifndef __HTTP_CONN__
#define __HTTP_CONN__

#include "../utilities/utilities.h"

class http_conn {
public:
  static const int FILENAME_LEN = 200;
  static const int READ_BUFFER_SIZE = 2048;
  static const int WRITE_BUFFER_SIZE = 4096;

public:
  http_conn();
  ~http_conn();

public:
  void init(int sockFd, const struct sockaddr_in &addr); //初始化新接受的连接
  void closeConn(bool real_close = true);                //关闭连接
  void process();                                        //处理客户请求
  bool read();                                           //非阻塞读
  bool write();                                          //非阻塞写

private:
  void init();
  void process_read();
  void process_write();
  void sendRespond();

private:
  int m_socketFd;
  sockaddr_in clientAddr;

  char m_read_buff[READ_BUFFER_SIZE];

public:
  static int epollFd;
  static int myUserCnt;
};

#endif